/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-04-15
 * Time: 15:35
 */
public class test3 {
    /**
     * 冒泡排序   稳定   n^2
     */

    public static void main(String[] args) {
        int[] arr = new int[]{1,2,5,7,3,32,31,69};
        for(int x:arr){
            System.out.print(x+" ");
        }
        bubbleSort(arr);
        System.out.println();
        for(int x:arr){
            System.out.print(x+" ");
        }
    }

    public static void bubbleSort(int[] arr){
        for(int i=0;i<arr.length;i++){
            for(int j=i+1;j< arr.length;j++){
                if(arr[i]>arr[j]){
                    int tmp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = tmp;
                }
            }
        }
    }
}
